<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>权限列表</title>
<script type="text/javascript" src="../static/plugin/zTree_v3/js/jquery-1.4.4.min.js"></script>
<link rel="stylesheet" type="text/css" href="../static/plugin/zTree_v3/css/zTreeStyle/zTreeStyle.css">
<script type="text/javascript" src="../static/plugin/zTree_v3/js/jquery.ztree.all.min.js"></script>

</head>
<body>

	<%-- 	${menuList} --%>
<script type="text/javascript">
$(document).ready(function(){
	
	$("form").submit(function(e){
			var ids = [], nodes = tree.getCheckedNodes(true);
			for(var i=0; i<nodes.length; i++) {
				ids.push(nodes[i].id);
			}
			$("#menuIds").val(ids);
			loading('正在提交，请稍等...');
			form.submit();
		})
	

	var setting = {
		    "check": {
		        "enable": true,
		        "nocheckInherit": true
		    },
		    "view": {
		        "selectedMulti": false
		    },
		    "data": {
		        "simpleData": {
		            "enable": true
		        }
		    },
		    "callback": {}
		};
	
	// 用户-菜单
	
	var zNodes= eval('${menuList}');
	// 初始化树结构
	var tree = $.fn.zTree.init($("#menuTree"), setting, zNodes);
	// 不选择父节点
	tree.setting.check.chkboxType = { "Y" : "ps", "N" : "s" };
	setInterval(()=>{
		var treeObj = tree.getCheckedNodes();
		//var nodes = treeObj.getCheckedNodes(true);
		console.log(treeObj);
	},2000); 
	// 默认选择节点
	var ids = "".split(",");
	for(var i=0; i<ids.length; i++) {
		var node = tree.getNodeByParam("id", ids[i]);
		try{tree.checkNode(node, true, false);}catch(e){}
	}
	// 默认展开全部节点
	tree.expandAll(true);
	
	// 用户-机构
	/* var zNodes = eval('${menuList}') */
	/* var zNodes2=[
			{id:"1", pId:"0", name:"湖南省总公司"},
            {id:"2", pId:"1", name:"公司领导"},
            {id:"3", pId:"1", name:"综合部"},
            {id:"4", pId:"1", name:"市场部"},
            {id:"5", pId:"1", name:"技术部"},
            {id:"6", pId:"1", name:"研发部"},
            {id:"7", pId:"1", name:"长沙市分公司"},
            {id:"8", pId:"7", name:"公司领导"},
            {id:"9", pId:"7", name:"综合部"},
            {id:"10", pId:"7", name:"市场部"},
            {id:"11", pId:"7", name:"技术部"},
            {id:"12", pId:"7", name:"芙蓉区分公司"},
            {id:"13", pId:"12", name:"公司领导"},
            {id:"14", pId:"12", name:"综合部"},
            {id:"15", pId:"12", name:"市场部"},
            {id:"16", pId:"12", name:"技术部"},
            ]; */
	
})
/* var treeObj = $.fn.zTree.getZTreeObj("tree");
var nodes = treeObj.getCheckedNodes(true);
console.log(nodes); */
/* var checkedObjs = tree.getCheckedNodes(true);  //获取所有选中的节点
    if(checkedObjs.length!=3){
        layer.alert("必须选择3个产品");
        flag=false;
        return;
    } */
   


</script>

<h1>${tgId}</h1>
<form id="form" class="form-horizontal" action="${pageContext.request.contextPath}/sys/role.do?method=giveMenuToRole&tgId=${tgId}" method="post">
<!-- 		
<script type="text/javascript">top.$.jBox.closeTip();</script> -->

	
		
		
		
		<div class="control-group">
			<label class="control-label">角色授权:</label>
			<div class="controls">
				<div id="menuTree" class="ztree" style="margin-top:3px;float:left;"></div>
				<input id="menuIds" name="menuIds" type="hidden" value=""/>
				角色编号：<input type = "text" name = "roleid"><br>
				角色名称：<input type = "text" name = "rolename"><br>
				角色描述：<input type = "text" name = "roledescribe"><br>
				
			</div>
		</div>
		
		<div class="form-actions">
			
				<input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;
			
			
		</div>
	</form>






</body>
</html>



















